﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using NewtifyMe.DataTypes;
using System.Net;

namespace NewtifyMe.ParseFeeds
{
    public class Deserialize
    {
        public static XFeed GetFeed ()
        {

            String url = "http://www.rtp.pt/noticias/index.php?tm=4&headline=204&visual=58";


            System.Net.HttpWebRequest request;
            request = (System.Net.HttpWebRequest) WebRequest.Create(url);

            XFeed result;

            using (WebResponse response = request.GetResponse() )
            {
                using (Stream stream = response.GetResponseStream()) 
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(XFeed));

                    result = (XFeed)serializer.Deserialize(stream);
                }

            }

            return result;

        }

    }
}
